package com.itheima.pattern.command;

import java.util.ArrayList;
import java.util.function.Consumer;

public class Waitor {
    private ArrayList<Command> commands=new ArrayList<>();//命令集

    public void setCommands(Command cmd){
        commands.add(cmd);
    }

    //发出命令
    public void orderUp(){
        System.out.println("美女服务员：大厨，订单来了。。。。。");
        commands.forEach(new Consumer<Command>() {
            @Override
            public void accept(Command command) {
                command.execute();
            }
        });
    }
}
